package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 集合实体类
 * 对应数据库collection表，用于组织文档笔记
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "collection")
@TableName("collection")
@Schema(description = "文档集合模型")
public class DocCollection extends BaseEntity {

    @Id
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "集合ID(自增主键)", example = "1")
    private Long id;

    @Column(nullable = false)
    @TableField
    @Schema(description = "所属用户ID", example = "1")
    private Long userId;

    @Column
    @TableField
    @Schema(description = "父级集合ID", example = "0")
    private Long parentId;

    @Column(nullable = false)
    @TableField
    @Schema(description = "集合名称", example = "学习笔记")
    private String name;

    @Column
    @TableField
    @Schema(description = "集合描述", example = "这是一个学习笔记的集合")
    private String description;
    
    @Column
    @TableField
    @Schema(description = "图片地址", example = "https://example.com/image.jpg")
    private String icon;
    
    @Column
    @TableField
    @Schema(description = "表情符号", example = "📁")
    private String emoji;

    @TableField
    @Schema(description = "删除标记 0:正常 1:删除", example = "0")
    private Integer deleted = 0;

    @Column(name = "created_at")

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 